package com.boatAnchorAssistant.service.controller.web;

import com.boatAnchorAssistant.pojo.param.eventGroup.*;
import com.boatAnchorAssistant.pojo.vo.eventGroup.*;
import com.boatAnchorAssistant.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

/**
 * web/事件分组
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/eventGroup/web")
public class EventGroupWebController {

    private final EventGroupService service;

    public EventGroupWebController(EventGroupService service) {
        this.service = service;
    }


    /**
     * 创建事件分组
     *
     * @param param
     * @return
     */
    @PostMapping("/createEventGroup")
    public ApiResult createEventGroup(@RequestBody @Valid CreateEventGroupParam param) {
        service.createEventGroup(param);
        return ApiResult.ok();
    }


    /**
     * 修改事件分组
     *
     * @param param
     */
    @PutMapping("/editEventGroup")
    public ApiResult editEventGroup(@RequestBody @Valid EditEventGroupParam param) {
        service.editEventGroup(param);
        return ApiResult.ok();
    }

    /**
     * 移除事件分组
     *
     * @param id
     */
    @DeleteMapping("/removeEventGroup")
    public ApiResult removeEventGroup(@RequestParam("id") Long id) {
        service.removeEventGroup(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用事件分组
     *
     * @param id
     */
    @GetMapping("/enabledEventGroup")
    public ApiResult enabledEventGroup(@RequestParam("id") Long id) {
        service.enabledEventGroup(id);
        return ApiResult.ok();
    }

    /**
     * 获取事件分组详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getEventGroup")
    public ApiResult<GetEventGroupVo> getEventGroup(@RequestParam("id") Long id) {
        GetEventGroupVo vo = service.getEventGroup(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取事件分组列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getEventGroupList")
    public ApiResult<PageResult<GetEventGroupListVo>> getEventGroupList(@RequestBody GetEventGroupListParam param) {
        PageResult<GetEventGroupListVo> result = service.getEventGroupList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取事件分组下拉列表
     *
     * @return
     */
    @PostMapping("/getEventGroupDownList")
    public ApiResult<List<GetEventGroupDownListVo>> getEventGroupDownList(@RequestBody(required = false) @Valid GetEventGroupDownListParam param) {
        List<GetEventGroupDownListVo> list = service.getEventGroupDownList(param);
        return ApiResult.ok(list);
    }


}

